// JavaScript Document
	var curIndex = 0;
jQuery(function($){
	if (self.location != top.location) { 
		top.location.href = self.location.href; 
	} 
	$("body").layout({
		north__size:		130
	,	north__closable:	false
	,	north__spacing_open:	0
	,	south__size:		8
	,	south__closable:	false
	,	south__spacing_open:	0
	,	west__size:			190
	,	west__resizable:	false
	,	east__size:			8
	,	east__closable:		false
	,	east__spacing_open:	0
	,	spacing_closed:		8
	,	togglerTip_open: "关闭"
	,	togglerTip_closed: "展开"
	,	onclose: function(pane_name){if(pane_name=='west') {$('#top_msg_menu').hide();$('#top_menu_split').hide();$('#top_menu_icon').removeClass('ui-icon-pin-s').addClass('ui-icon-pin-w');}}
	,	onopen: function(pane_name){if(pane_name=='west') {$('#top_msg_menu').show();$('#top_menu_split').show();$('#top_menu_icon').removeClass('ui-icon-pin-w').addClass('ui-icon-pin-s');}}
	});
	initLeftMenu();
	
	$("#sysbar button:first").button({
        icons: {
            primary: 'ui-icon-key'
        }
    }).next().button({
        icons: {
            primary: 'ui-icon-person'
        }
    }).next().button({
        icons: {
            primary: 'ui-icon-mail-closed'
        }
    }).next().button({
        icons: {
            primary: 'ui-icon-extlink'
        }    
    });

	$("#theme").dialog({
		bgiframe: false,
		autoOpen:false,
		resizable :false,
		position: 'top',
		width: 320,
		height: 110,
		modal: true
	});
	
	$("#datepicker").datepickerlunar({
		showMonthAfterYear: true,
		changeMonth: true,
		changeYear: true
	});

	$('#datepicker').position({
		"my": "right top",
		"at": "right bottom",
		"of": $('.date'),
		"offset": "-20 -3",
		"collision": "fit flip",
		"bgiframe": true
	});
	
	$('.date').click(function(){
		$('#datepicker').slideToggle();
	});
	
	$('#date').jclock({withDate:true, withWeek:true,dispstr:'时间：%date(%week) %time'});

//	showBulletin();
//	setInterval("showBulletin()",60000);
	$("#bulletin_close").click(function(){$("#bulletin").slideUp();});

	$("#bulletin_close").hover(
		function(){
			$(this).addClass("ui-state-hover");
		},
		function(){
			$(this).removeClass("ui-state-hover");
		}
	);
	

});

function initLeftMenu() {
	var menu = '';

	// 考核管理
//	menu += '<h3><a href="#">'+'考核管理'+'</a></h3><div style="overflow-x:hidden;padding-bottom:1px">';
//	menu += '<a href="'+'about:blank'+'" target="maincontent" class="a"><div class="menu"><div class=" ui-icon ui-icon-document-b menu-background-two"></div>'+'考核设置'+'</div></a>';
//	menu += '</div>';
	
	// 系统管理
	menu += '<h3><a href="#">'+'系统管理'+'</a></h3><div style="overflow-x:hidden;padding-bottom:1px">';
	menu += '<a href="'+'system/user/showUserJsp.action'+'" target="maincontent" class="a"><div class="menu"><div class=" ui-icon ui-icon-document-b menu-background-two"></div>'+'用户管理'+'</div></a>';
	menu += '<a href="'+'system/department/showDeptJsp.action'+'" target="maincontent" class="a"><div class="menu"><div class=" ui-icon ui-icon-document-b menu-background-two"></div>'+'部门管理'+'</div></a>';
	menu += '</div>';
	
	$('#accordion').html(menu);
	$("#accordion").accordion({
		fillSpace: true
	});

	$('#menu').menuTree({
    });
	
	$('.menu').hover( function() {
		$(this).addClass("ui-state-hover");
	}, function() {
		$('.menu').removeClass("ui-state-hover");
	});
	
	$('.menu').click(function(){
		$('.menu').removeClass("ui-state-highlight");
		$(this).addClass("ui-state-highlight");
	});
	$('.navhome').click(function(){
		$('.menu').removeClass("ui-state-highlight");
	});
}

//弹出未读消息提示框
function showBulletin(){
	$.ajax({  
	    url: 'pw/message/loadUnreadMessage.action',   
	    type:'POST',   
	    dataType: 'json',
		beforeSend:function(xmlhttprequest){
	 	},
		success:function(data){
	 		if(data.unreadCount<1){
	 			$("#bulletin").slideUp();
	 		}else{
	 			if (data.newSendUsers != null) {
		 			$('#newSendUsers').html(data.newSendUsers);  
	 			} else {
	 				$('#unreadCount').html(data.unreadCount);  
	 			}
	 			
	 			$("#bulletin").slideDown();
	 		}
		 },
		 error:function(){
			 $("#bulletin").slideUp();
		 }
	 });
}

function openTheme(){
	$('#theme').dialog('open');
}

function changeTheme(theme){
	location.href = "saveUserTheme.action?theme="+theme;
}

